/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package blink.model;

import java.io.File;
import java.io.PrintWriter;

/**
 *
 * @author jerome
 */
public class ExperimentRenderer {
    
    public static char SEP='\t';
    
    private PrintWriter out;
    
    public ExperimentRenderer(PrintWriter out) {
        this.out=out;
    }
    
    public static StringBuffer renderExperiment(Experiment e) {
        StringBuffer sb = new StringBuffer();
        sb.append(e.getSubjectName());
        sb.append(SEP);
        sb.append(e.getSubjectLastname());
        sb.append(SEP);
        sb.append(e.getAge());
        sb.append('\n');
        sb.append(e.getComment());
         
        for (Task t : e.getTasks()) {
            sb.append('\n');
            renderTask(t,sb);
        }
        
        return sb;
    }
    
    
    public static StringBuffer renderTrial(Trial t) {
        StringBuffer sb = new StringBuffer();
        sb.append(t.getTask().getName());
        for (int i=0 ; i<t.getUserResponses().length; i++) {
            sb.append(t.getUserResponses()[i]);
            sb.append(SEP);
            sb.append(t.getCorrectResponses()[i]);
        }
        sb.append('\n');
        
        return sb;
    }

    private static void renderTask(Task t, StringBuffer sb) {
        sb.append(t.getName());
        sb.append(SEP);
        sb.append(t.getDisplayTime());
        sb.append(SEP);
        sb.append(t.getLagTime());
        sb.append(SEP);
        sb.append(t.getMinGapBetweenFillers());
        sb.append('\n');
    }
}
